<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>父子组件传值</title>
    <script src="../lib/vue_v2.6.14.js"></script>
  </head>
  <body>
    <div id="app">
      <my-cpn :movies="movies"></my-cpn>
    </div>

    <template id="cpn">
      <ul>
        <li v-for="(item, index) in movies" :key="index">{{ item }}</li>
      </ul>
    </template>
    <script>
      // 子组件
      Vue.component('my-cpn', {
        template: '#cpn',
        props: ['movies']
      })

      // vue实例充当父组件
      const vm = new Vue({
        el: '#app',
        data: {
          movies: ['速度与激情', '拆弹专家', '银河补习班', '敢死队']
        }
      })
    </script>
  </body>
</html>
